﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Thrift.Protocol;
using Thrift.Server;
using Thrift.Transport;

namespace Thrift.Server
{
    /// <summary>
    /// TsingDa.Tools服务端工厂，用来保持服务状态，服务的开启
    /// 各个服务都需要通过MultiplexedProcessor进行注册
    /// </summary>
    public class ServiceFactory
    {

        /// <summary>
        /// 单例模式下的实例集合，保证它的只有一个对象
        /// </summary>
        public static readonly TMultiplexedProcessor MultiplexedProcessor = new TMultiplexedProcessor();

        public static void Start()
        {
            //远程登陆调用
            new Thread(() =>
            {
                var serverTransport = new TServerSocket(9900);//port会从配置中读取
                var server1 = new TSimpleServer(MultiplexedProcessor, serverTransport);
                Console.WriteLine("开启基础服务...");
                server1.Serve();
            }).Start();

        }
    }
}
